bin_PROGRAMS = class2pic

CC=g++

INCLUDE = -I.
COMPISITE_SOURCES = \
	CxxLexer.cpp \
	CxxParser.cpp \
	CxxToken.cpp

CSOURCES  = tree.c dot.c class2pic.c

DUMMYDIR=dummy
DUMMYFILE=${DUMMYDIR}/osfcn.h

class2pic_LDFLAGS =  

YACCFLAGS = -d -t -v -y

_SOURCES = $COMPISITE_SOURCES $CSOURCES $DUMMYFILE

class2pic_LDADD = CxxLexer.o CxxParser.o CxxToken.o dot.o tree.o @LEXLIB@

CxxLexer.o : CxxLexing.cxx CxxLexing.hxx CxxToken.hxx CxxLexer.cxx CxxParser.hxx ${DUMMYFILE}

CxxParser.o : CxxParsing.cxx CxxParsing.hxx CxxToken.hxx CxxParser.cxx CxxParser.hxx

CxxToken.o : CxxToken.cxx CxxToken.hxx

dot.o : dot.c

tree.o : tree.c

%.cxx %.hxx : %.y
	@- ${YACC} ${YACCFLAGS} $*.y
	@- mv -f y.tab.c $*.cxx
	@- mv -f y.tab.h $*.hxx
	@- chmod -w $*.cxx $*.hxx
	@- sh -c 'echo "bison file compiled"'

%.cxx : %.l
	@- $(LEX) $*.l
	@- mv -f lex.yy.c $*.cxx
	@- chmod -w $*.cxx
	@- sh -c 'echo "lex file compiled"'

$(DUMMYDIR)/osfcn.h :
	@- sh -c 'if test ! -d "$(@D)"; then echo mkdir -p "$(@D)"; mkdir -p "$(@D)"; fi'
	@- echo '$@'
	@- sh -c 'echo "extern \"C\" int read(int, char *, int);" > "$@"'
	@- sh -c 'chmod -w "$@"'


%.o : %.cpp
	@- echo $@
	@- if $(CC) -c -O $(CXXFLAGS) $(INCLUDE) -o $*.o $< ;\
		then : ; else rm -f $*.o; fi
$(TARGET) : $(LIB_OBJS) $(C_SOURCES:%.c=%.o)
	- $(CC) $(CXXFLAGS) $(INCLUDE) -o $(TARGET)  \
		$(LIB_OBJS) $(LINK_LIBS)


PARSER_FILE = CxxParser.hxx CxxParser.cxx

LEXER_FILE = CxxLexer.cxx 

#info_TEXINFOS = class2pic.texi

PARSER_FILE = CxxParser.hxx CxxParser.cxx
LEXER_FILE = CxxLexer.cxx 

clean:
	- rm -f *.o ${DUMMYDIR}/*  ${PARSER_FILE} ${LEXER_FILE} y.* 
